From 80031349d5d6c9eda98781bdc7346739bdca8143 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Mon, 21 Dec 2009 10:39:48 +0000 Subject: [PATCH] xenstore: Fix memory leak in command 'xenstore rm' When option '-t' is used to do tidy remove, routine xs_directory() will be called in order to check there are brother directories or not. The returned pointer should be passed to free() after this check. Signed-off-by: Yu Zhiguo --- tools/xenstore/xenstore_client.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/xenstore/xenstore_client.c b/tools/xenstore/xenstore_client.c index aaf3014d53..50fc3d7646 100644 --- a/tools/xenstore/xenstore_client.c +++ b/tools/xenstore/xenstore_client.c @@ -343,8 +343,10 @@ perform(enum mode mode, int optind, int argc, char **argv, struct xs_handle *xsh unsigned int num; char ** list = xs_directory(xsh, xth, p, &num); - if (list && num == 0) { - goto again; + if (list) { + free(list); + if (num == 0) + goto again; } } } -- 2.30.2